import 'dart:async';
import 'dart:io';

import 'package:flutter/services.dart';

class AliLog {
  static const MethodChannel _channel =
      const MethodChannel('ali_log');

  static Future<String?> get platformVersion async {
    final String? version = await _channel.invokeMethod('getPlatformVersion');
    return version;
  }

  static void postDartError(String error, String stack) {
    print('AliLog.postDartError');
    if(Platform.isAndroid) {
      Map<String, dynamic> map = Map();
      map['error'] = error;
      map['stack'] = stack;
      _channel.invokeMethod('postDartError', map);
    }
  }

  static void postHttpLog(String url, String paramsJson, String responseJson){
    print('AliLog.postHttpLog');
    if(Platform.isAndroid) {
      Map<String, dynamic> map = Map();
      map['url'] = url;
      map['paramsJson'] = paramsJson;
      map['responseJson'] = responseJson;
      _channel.invokeMethod('postHttpLog', map);
    }
  }
}
